<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
    <title>Authenticating with ClientLogin - Zend Framework Manual</title>

    <link href="../css/shCore.css" rel="stylesheet" type="text/css" />
    <link href="../css/shThemeDefault.css" rel="stylesheet" type="text/css" />
    <link href="../css/styles.css" media="all" rel="stylesheet" type="text/css" />
</head>
<body>
<h1>Zend Framework</h1>
<h2>Programmer's Reference Guide</h2>
<ul>
    <li><a href="../en/zend.gdata.clientlogin.html">Inglês (English)</a></li>
    <li><a href="../pt-br/zend.gdata.clientlogin.html">Português Brasileiro (Brazilian Portuguese)</a></li>
</ul>
<table width="100%">
    <tr valign="top">
        <td width="85%">
            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.gdata.books.html">Using the Book Search Data API</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.gdata.html">Zend_Gdata</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.gdata.calendar.html">Using Google Calendar</a></div>
                    </td>
                </tr>
            </table>
<hr />
<div id="zend.gdata.clientlogin" class="section"><div class="info"><h1 class="title">Authenticating with ClientLogin</h1></div>
    

    <p class="para">
        The ClientLogin mechanism enables you to write <acronym class="acronym">PHP</acronym> application
        that acquire authenticated access to Google Services,
        specifying a user&#039;s credentials in the <acronym class="acronym">HTTP</acronym> Client.
    </p>

    <p class="para">
        See <a href="http://code.google.com/apis/accounts/AuthForInstalledApps.html" class="link external">&raquo; http://code.google.com/apis/accounts/AuthForInstalledApps.html</a>
        for more information about Google Data ClientLogin authentication.
    </p>

    <p class="para">
        The Google documentation says the ClientLogin mechanism is appropriate
        for &quot;installed applications&quot; whereas the AuthSub mechanism is
        for &quot;web applications.&quot; The difference is that AuthSub requires
        interaction from the user, and a browser interface that can react
        to redirection requests. The ClientLogin solution uses <acronym class="acronym">PHP</acronym> code to
        supply the account credentials; the user is not required to enter her
        credentials interactively.
    </p>

    <p class="para">
        The account credentials supplied via the ClientLogin mechanism must
        be valid credentials for Google services, but they are not required
        to be those of the user who is using the <acronym class="acronym">PHP</acronym> application.
    </p>

    <div class="section" id="zend.gdata.clientlogin.login"><div class="info"><h1 class="title">Creating a ClientLogin authenticated Http Client</h1></div>
        

        <p class="para">
            The process of creating an authenticated <acronym class="acronym">HTTP</acronym> client using
            the ClientLogin mechanism is to call the static function
             <span class="methodname">Zend_Gdata_ClientLogin::getHttpClient()</span>
            and pass the Google account credentials in plain text.
            The return value of this function is an object of class
            <span class="classname">Zend_Http_Client</span>.
        </p>

        <p class="para">
            The optional third parameter is the name of the Google Data
            service. For instance, this can be &#039;cl&#039; for Google Calendar.
            The default is &quot;xapi&quot;, which is recognized by Google Data
            servers as a generic service name.
        </p>

        <p class="para">
            The optional fourth parameter is an instance of <span class="classname">Zend_Http_Client</span>.
            This allows you to set options in the client, such as proxy
            server settings. If you pass <b><tt>NULL</tt></b> for this
            parameter, a generic <span class="classname">Zend_Http_Client</span> object is created.
        </p>

        <p class="para">
            The optional fifth parameter is a short string that Google Data
            servers use to identify the client application for logging
            purposes. By default this is string &quot;Zend-ZendFramework&quot;;
        </p>

        <p class="para">
            The optional sixth parameter is a string ID for a
            <span_trademark class="trademark">CAPTCHA</span_trademark> challenge that has been issued by
            the server. It is only necessary when logging in after receiving
            a <span_trademark class="trademark">CAPTCHA</span_trademark> challenge from a previous
            login attempt.
        </p>

        <p class="para">
            The optional seventh parameter is a user&#039;s response to a
            <span_trademark class="trademark">CAPTCHA</span_trademark> challenge that has been issued by
            the server. It is only necessary when logging in after receiving
            a <span_trademark class="trademark">CAPTCHA</span_trademark> challenge from a previous
            login attempt.
        </p>

        <p class="para">
            Below is an example of <acronym class="acronym">PHP</acronym> code for a web application
            to acquire authentication to use the Google Calendar service
            and create a <span class="classname">Zend_Gdata</span> client object using that authenticated
            <span class="classname">Zend_Http_Client</span>.
        </p>

        <pre class="programlisting brush: php">
// Enter your Google account credentials
$email = &#039;johndoe@gmail.com&#039;;
$passwd = &#039;xxxxxxxx&#039;;
try {
   $client = Zend_Gdata_ClientLogin::getHttpClient($email, $passwd, &#039;cl&#039;);
} catch (Zend_Gdata_App_CaptchaRequiredException $cre) {
    echo &#039;URL of CAPTCHA image: &#039; . $cre-&gt;getCaptchaUrl() . &quot;\n&quot;;
    echo &#039;Token ID: &#039; . $cre-&gt;getCaptchaToken() . &quot;\n&quot;;
} catch (Zend_Gdata_App_AuthException $ae) {
   echo &#039;Problem authenticating: &#039; . $ae-&gt;exception() . &quot;\n&quot;;
}

$cal = new Zend_Gdata_Calendar($client);
</pre>

    </div>

    <div class="section" id="zend.gdata.clientlogin.terminating"><div class="info"><h1 class="title">Terminating a ClientLogin authenticated Http Client</h1></div>
        

        <p class="para">
            There is no method to revoke ClientLogin authentication as there
            is in the AuthSub token-based solution. The credentials used
            in the ClientLogin authentication are the login and password
            to a Google account, and therefore these can be used repeatedly
            in the future.
        </p>
    </div>
</div>
        <hr />

            <table width="100%">
                <tr>
                    <td width="25%" style="text-align: left;">
                    <a href="zend.gdata.books.html">Using the Book Search Data API</a>
                    </td>

                    <td width="50%" style="text-align: center;">
                        <div class="up"><span class="up"><a href="zend.gdata.html">Zend_Gdata</a></span><br />
                        <span class="home"><a href="manual.html">Programmer's Reference Guide</a></span></div>
                    </td>

                    <td width="25%" style="text-align: right;">
                        <div class="next" style="text-align: right; float: right;"><a href="zend.gdata.calendar.html">Using Google Calendar</a></div>
                    </td>
                </tr>
            </table>
</td>
        <td style="font-size: smaller;" width="15%"> <style type="text/css">
#leftbar {
	float: left;
	width: 186px;
	padding: 5px;
	font-size: smaller;
}
ul.toc {
	margin: 0px 5px 5px 5px;
	padding: 0px;
}
ul.toc li {
	font-size: 85%;
	margin: 1px 0 1px 1px;
	padding: 1px 0 1px 11px;
	list-style-type: none;
	background-repeat: no-repeat;
	background-position: center left;
}
ul.toc li.header {
	font-size: 115%;
	padding: 5px 0px 5px 11px;
	border-bottom: 1px solid #cccccc;
	margin-bottom: 5px;
}
ul.toc li.active {
	font-weight: bold;
}
ul.toc li a {
	text-decoration: none;
}
ul.toc li a:hover {
	text-decoration: underline;
}
</style>
 <ul class="toc">
  <li class="header home"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="manual.html">Programmer's Reference Guide</a></li>
  <li class="header up"><a href="reference.html">Zend Framework Reference</a></li>
  <li class="header up"><a href="zend.gdata.html">Zend_Gdata</a></li>
  <li><a href="zend.gdata.introduction.html">Introduction</a></li>
  <li><a href="zend.gdata.authsub.html">Authenticating with AuthSub</a></li>
  <li><a href="zend.gdata.books.html">Using the Book Search Data API</a></li>
  <li class="active"><a href="zend.gdata.clientlogin.html">Authenticating with ClientLogin</a></li>
  <li><a href="zend.gdata.calendar.html">Using Google Calendar</a></li>
  <li><a href="zend.gdata.docs.html">Using Google Documents List Data API</a></li>
  <li><a href="zend.gdata.health.html">Using Google Health</a></li>
  <li><a href="zend.gdata.spreadsheets.html">Using Google Spreadsheets</a></li>
  <li><a href="zend.gdata.gapps.html">Using Google Apps Provisioning</a></li>
  <li><a href="zend.gdata.gbase.html">Using Google Base</a></li>
  <li><a href="zend.gdata.photos.html">Using Picasa Web Albums</a></li>
  <li><a href="zend.gdata.youtube.html">Using the YouTube Data API</a></li>
  <li><a href="zend.gdata.exception.html">Catching Gdata Exceptions</a></li>
 </ul>
 </td>
    </tr>
</table>

<script type="text/javascript" src="../js/shCore.js"></script>
<script type="text/javascript" src="../js/shAutoloader.js"></script>
<script type="text/javascript" src="../js/main.js"></script>

</body>
</html>